home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Resources / Chat & Communication / Digsby build 37 / digsby_setup.exe / lib / gui / uberwidgets / htmllabel.pyo (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2008-10-13  |  1.9 KB  |  42 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyo (Python 2.5)
  3.  
  4. import wx
  5. from gui.textutil import default_font
  6. from wx.html import HtmlWindow, HW_SCROLLBAR_NEVER, HW_NO_SELECTION, EVT_HTML_LINK_CLICKED
  7.  
  8. class HTMLLabel(HtmlWindow):
  9.     
  10.     def __init__(self, parent, label, **callbacks):
  11.         HtmlWindow.__init__(self, parent, style = HW_SCROLLBAR_NEVER | HW_NO_SELECTION)
  12.         self.SetLabel(label, **callbacks)
  13.         self.SetCursor(wx.StockCursor(wx.CURSOR_DEFAULT))
  14.         self.SetBorders(0)
  15.         self.SetFonts(default_font().FaceName, 'Courier New')
  16.         self.Bind(EVT_HTML_LINK_CLICKED, self._on_link)
  17.  
  18.     
  19.     def SetLabel(self, label, **callbacks):
  20.         if '<html>' not in label:
  21.             label = '<html><body bgcolor="%s" padding=0 margins=0><font size="2">' % self.Parent.BackgroundColour.GetAsString(wx.C2S_HTML_SYNTAX) + label + '</font></body></html>'
  22.         
  23.         dc = wx.MemoryDC()
  24.         dc.Font = default_font()
  25.         self.Size = self.MinSize = dc.GetTextExtent(label)
  26.         self.SetPage(label)
  27.         self.callbacks = callbacks
  28.  
  29.     Label = property(HtmlWindow.ToText, SetLabel)
  30.     
  31.     def _on_link(self, e):
  32.         url = e.GetLinkInfo().Href
  33.         
  34.         try:
  35.             cb = self.callbacks[url]
  36.         except KeyError:
  37.             wx.LaunchDefaultBrowser(url)
  38.  
  39.         cb()
  40.  
  41.  
  42.